package com.wenson.behavior.memento;

/**
 * @ClassName: Doc
 * @Author: luowangcheng
 * @Date: 2024/6/16 8:24
 * @Description:
 */
public class Doc {
    private String title;
    private String body;

    public Doc(String title) {
        this.title = title; //新建文档先命名
        this.body = ""; //新建文档内容为空
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }

    public History createHistory(){
        return new History(body);//创建历史记录
    }

    public void restoreHistory(History history){
        this.body = history.getBody();//恢复历史记录
    }
}
